import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
     public static boolean[] ret;
    public static int v;
    public static int min;

    public static void main(String[] args) {
        int[] nums=new int[]{1,2,3,4};
        int n=nums.length;
        int[] arr=new int[n];
        int[] arr1=new int[n];
        int[] ar=new int[n];
        arr[0]=1;
        arr1[n-1]=1;
        for(int j=1;j<n;j++) arr[j]=arr[j-1]*nums[j-1];
        for(int j=n-2;j>=0;j--) arr1[j]=arr1[j+1]*nums[j+1];

        for(int i=1;i<n;i++) ar[i]=arr[i]*arr1[i];
    }
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
            v = in.nextInt();
            int n= in.nextInt();
             min=v;
      int[] arr=new int[n];
           ret=new boolean[n];
      for(int i=0;i<n;i++)  arr[i]=in.nextInt();
      dfs(arr,0,0);
      System.out.println(min);
    }
    public static void dfs(int[] arr,int sum,int i){
        if(sum>=v||i>=arr.length){
            return;
        }
  for(int j=i;j<arr.length;j++){
      min= Math.min(min,v-sum);
      sum+=arr[j];
      dfs(arr,sum,j+1);

  }
    }
}